<div class="content <%= order_made.status %>">
  <div class="title">
    <div class="name"><%= order_made.factory.name %></div>
    <div class='status corner'>
      <%= t order_made.status %>
    </div>
    <div class='order_made_form_no'>
      <%= order_made.order_made_no %>
    </div>
  </div>
  <div class='fields'>
    <dl>
      <dt>日期:</dt>
      <dd><%= order_made.order_made_on %></dd>
      <dt>金额:</dt>
      <dd><%= number_with_precision(order_made.order_made_price, :precision => 2) %></dd>
    </dl>
    <dl>      
      <dt>联系:</dt>
      <dd class='l'><%= order_made.factory.link_man %>-<%= order_made.factory.link_phone %></dd>
    </dl>
    <dl>      
      <dt>地址:</dt>
      <dd class='l'><%= order_made.factory.address %></dd>
    </dl>
  </div>    
  <div class='furnitures'>
    <table cellspacing='1' cellpadding='1'>
      <tr>
        <th>型号</th>
        <th>名称</th>
        <th>材质</th>
        <th>规格</th>
        <th>件数</th>
        <th>来源</th>
      </tr>
      <% order_made.order_made_items.each do |item| %>
      <tr id='item_<%= item.id %>' class='order_made_item <%= cycle '','hh', :name => 'furniture_item' %>'>
        <td><%= item.furniture.furniture_style.code %></td>
        <td><%= item.furniture.furniture_style.name %></td>
        <td><%= item.furniture.material.code %>-<%= item.furniture.material.name %></td>
        <td><%= item.furniture.spec %></td>
        <td><%= item.order_made_count %></td>
        <td>
          <% if item.source.ordered? %>
          <%= link_to t(item.source), item.order,:target => :_blank, :title => "来自-预订单【#{item.order.order_no}】" %>
          <% elsif item.source.after_serviced? %>
          <%= link_to t(item.source), item.installation,:target => :_blank, :title => "来自-安装单【#{item.installation.install_no}】" %>
          <% else %>
          <%= t item.source %>
          <% end %>
        </td>
      </tr>
      <tr id='events_<%= item.id %>' class='item_events'>
        <td colspan='6'>
          <table class='events' cellspacing="1" cellpadding="1">
            <tr>
              <th></th>
              <th>描述</th>
              <th>登记人</th>                    
            </tr>
            <% item.feeds.each_with_index do |feed,index| %>
            <tr class='<%= cycle '','hh', :name => 'event' %>'>
              <td><%= index + 1 %>.</td>
              <td class='d'><%=raw feed.short_desc %><%= raw feed.remark.present? ? "<br/><b>备注：</b>#{raw(feed.remark) }" : '' %></td>
              <td><%= order_made.creator.full_name %></td>                    
            </tr>
            <% end %>
          </table>
        </td>
      </tr>
      <script type="text/javascript" charset="utf-8">
        $('#item_<%= item.id %>').toggle(
          function() {
            $(this).addClass('h');
            $('#events_<%= item.id %>').show('slow');
          },
          function() {
            $(this).removeClass('h');
            $('#events_<%= item.id %>').hide();
          }
        );
      </script>
      <% end %>
    </table>
  </div>
  <% if order_made.remark.present? %>
  <dl class="remark">
    <dt>特殊说明:</dt> 
    <dd><%= order_made.remark %></dd>
  </dl>
  <% end %>
</div>
<div class="operate">
  <%= link_to "查看详情", order_made_url(order_made) , :class => :button, :target => :_blank %>
  <%= link_to order_made.status.being_edited? ? "继续编辑" : (order_made.status.blanked_out? ? "重新打开" : "编辑订单"), edit_order_made_url(order_made) , :class => :button %>
  <%= link_to "作废此单", order_made_url(order_made) , :remote => true, :method => :delete, :class => :button if not order_made.status.blanked_out? %>
</div>